const demoname = {
    login: 'login',
    out: 'out',
}
	let nickName =uni.getStorageSync('nickName')
	let avatarUrl =uni.getStorageSync('avatarUrl')
	let token =uni.getStorageSync('token')
const store = {
    state: {
      nickName,
      avatarUrl,
      token,
	  refresh:'',
	  
    },
    getters: {
        getLocale: state => {
            return state
        }
    },
    mutations: {
        [demoname.login]: (state, localeVal) => {
           state.nickName =uni.getStorageSync('nickName')
           state.avatarUrl =uni.getStorageSync('avatarUrl')
           state.token =uni.getStorageSync('token')
           
        }  ,
         
		[demoname.out]: (state, localeVal) => {
		uni.showModal({
		    title: '提示',
		    content: '要登出小程序吗',
		    success: function (res) {
		        if (res.confirm) {
		          try {
		          		uni.removeStorageSync('token')
		          		uni.removeStorageSync('nickName')
		          		uni.removeStorageSync('avatarUrl')
		          		state.token=''
		          		state.avatarUrl=''
		          		state.nickName=''
		          				
		          	} catch {
		          		uni.showToast({
		          			icon: none,
		          			title: '退出失败,尝试重试'
		          		})
		          	}
		        } else if (res.cancel) {
		            console.log('用户点击取消');
		        }
		    }
		});
		
		}
    },
    actions: {
        demoactions: ({ commit }, localeVal) => {
            commit(demoname.fn, localeVal)
        }
    }
}
export default store